import { validate } from "lyz-vue-core";
// 数字
const number = /^[0-9]*$/;
// 汉字
const Chinese = /^[\u4e00-\u9fa5]{0,}$/;
// 身份证
const idcard =
  /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
// 手机号
const phone =
  /^\d{11}$/;
// 邮箱
const email = (str:string) => {
  let bol = true;
  if(!(str.indexOf('@') > -1 && str.indexOf('.') > -1)) {
    bol = false;
  }
  return bol;
};
//银行卡
const bankcard = /^([1-9]{1})(\d{15}|\d{16}|\d{18})$/;
const validateInstance = new validate();

validateInstance.register("number", number);
validateInstance.register("Chinese", Chinese);
validateInstance.register("idcard", idcard);
validateInstance.register("phone", phone);
validateInstance.register("email", email);
validateInstance.register("bankcard", bankcard);

export default validateInstance;
